package com.lfg.leetcode.leetcode1000;


import com.alibaba.fastjson.JSON;

public class No1109corpFlightBookings {
    public static void main(String[] args) {
        int[] ints = corpFlightBookings(new int[][]{{1,2,10}, {2,3,20}, {2,5,25}}, 5);
        System.out.println(JSON.toJSONString(ints));
    }

    public static int[] corpFlightBookings(int[][] bookings, int n) {
        int[] ret = new int[n + 1];
        for (int[] data : bookings) {
            ret[data[0] - 1] += data[2];
            ret[data[1]] -= data[2];
        }
        for (int i = 1; i < n; i++) {
            ret[i] += ret[i-1];
        }
        int[] list = new int[n];
        System.arraycopy(ret, 0, list, 0, n);
        return list;
    }

}



